/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FormPesanan.java
 *
 * Created on Nov 22, 2012, 2:08:06 PM
 */
package com.view;

import com.model.Pesanan;
import com.rekap.FormMenuTambah;
import com.rekap.view_pesanan;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.activation.*;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import prototype.mastermind;
import prototype.member;
import prototype.pesanan_kk;

/**
 *
 * @author Satellite
 */
public class FormPesanan extends javax.swing.JFrame {

    /**
     * Creates new form FormPesanan
     */
    public FormPesanan() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        background = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        labelnama = new javax.swing.JLabel();
        labelID = new javax.swing.JLabel();
        labelTelp = new javax.swing.JLabel();
        labelPaket = new javax.swing.JLabel();
        labelJumlah = new javax.swing.JLabel();
        labelHargaTotal = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();
        jTextField3 = new javax.swing.JTextField();
        jTextField4 = new javax.swing.JTextField();
        jTextField5 = new javax.swing.JTextField();
        jTextField6 = new javax.swing.JTextField();
        jTextField7 = new javax.swing.JTextField();
        cancel = new javax.swing.JButton();
        save = new javax.swing.JButton();
        labelTanggalJadi = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jTextField8 = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jDateChooser2 = new com.toedter.calendar.JDateChooser();
        jLabel6 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        file = new javax.swing.JMenu();
        home = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();
        menuEdit = new javax.swing.JMenu();
        order = new javax.swing.JMenuItem();
        lihatPesanan = new javax.swing.JMenuItem();
        paket = new javax.swing.JMenu();
        lihatDaftarPaket = new javax.swing.JMenuItem();
        tambahPaket = new javax.swing.JMenuItem();
        member = new javax.swing.JMenu();
        lihatMember = new javax.swing.JMenuItem();
        tambahMember = new javax.swing.JMenuItem();

        background.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/images/background.jpg"))); // NOI18N

        jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/images/background.jpg"))); // NOI18N

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBackground(new java.awt.Color(102, 255, 255));
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        labelnama.setText("Nama               :");
        getContentPane().add(labelnama, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 160, -1, -1));

        labelID.setText("ID Pesanan      :");
        getContentPane().add(labelID, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 100, -1, -1));

        labelTelp.setText(" No telp            :");
        getContentPane().add(labelTelp, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 220, 80, -1));

        labelPaket.setText("Paket               :");
        getContentPane().add(labelPaket, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 250, -1, -1));

        labelJumlah.setText("Jumlah             :");
        getContentPane().add(labelJumlah, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 280, -1, -1));

        labelHargaTotal.setText("Harga              :");
        getContentPane().add(labelHargaTotal, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 310, -1, -1));

        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });
        getContentPane().add(jTextField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 100, 150, -1));

        jTextField2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField2ActionPerformed(evt);
            }
        });
        getContentPane().add(jTextField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 130, 150, -1));

        jTextField3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField3ActionPerformed(evt);
            }
        });
        getContentPane().add(jTextField3, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 160, 222, -1));

        jTextField4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField4ActionPerformed(evt);
            }
        });
        getContentPane().add(jTextField4, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 190, 222, -1));

        jTextField5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField5ActionPerformed(evt);
            }
        });
        getContentPane().add(jTextField5, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 220, 150, -1));

        jTextField6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField6ActionPerformed(evt);
            }
        });
        getContentPane().add(jTextField6, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 250, 150, -1));

        jTextField7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField7ActionPerformed(evt);
            }
        });
        getContentPane().add(jTextField7, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 280, 100, -1));

        cancel.setText("Cancel");
        cancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelActionPerformed(evt);
            }
        });
        getContentPane().add(cancel, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 320, -1, -1));

        save.setText("Save");
        save.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveActionPerformed(evt);
            }
        });
        getContentPane().add(save, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 290, 70, -1));

        labelTanggalJadi.setText("Tanggal Jadi    :");
        getContentPane().add(labelTanggalJadi, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 340, -1, -1));

        jLabel1.setText(" Alamat            :");
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 190, -1, -1));

        jTextField8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField8ActionPerformed(evt);
            }
        });
        getContentPane().add(jTextField8, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 310, 150, -1));

        jLabel2.setText("ID Member       :");
        getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 130, -1, -1));

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel3.setText("PESANAN");
        getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 80, 90, -1));

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 10));
        jLabel4.setForeground(new java.awt.Color(204, 0, 0));
        jLabel4.setText("*jika tidak punya diberi (-)");
        getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 130, 130, 20));

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Lunas", "DP" }));
        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox1ActionPerformed(evt);
            }
        });
        getContentPane().add(jComboBox1, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 260, 70, -1));

        jDateChooser2.addAncestorListener(new javax.swing.event.AncestorListener() {
            public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
            }
            public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
                jDateChooser2AncestorAdded(evt);
            }
            public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
            }
        });
        getContentPane().add(jDateChooser2, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 340, 150, -1));

        jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/images/background.jpg"))); // NOI18N
        getContentPane().add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

        file.setText("File");

        home.setText("Home");
        home.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                homeActionPerformed(evt);
            }
        });
        file.add(home);

        jMenuItem2.setText("Logout");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        file.add(jMenuItem2);

        jMenuItem1.setText("Exit");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        file.add(jMenuItem1);

        jMenuBar1.add(file);

        menuEdit.setText("Pesanan");
        menuEdit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuEditActionPerformed(evt);
            }
        });

        order.setText("order");
        order.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                orderActionPerformed(evt);
            }
        });
        menuEdit.add(order);

        lihatPesanan.setText("lihat pesanan");
        lihatPesanan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lihatPesananActionPerformed(evt);
            }
        });
        menuEdit.add(lihatPesanan);

        jMenuBar1.add(menuEdit);

        paket.setText("Paket");

        lihatDaftarPaket.setText("lihat daftar Paket");
        lihatDaftarPaket.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lihatDaftarPaketActionPerformed(evt);
            }
        });
        paket.add(lihatDaftarPaket);

        tambahPaket.setText("tambah Paket");
        tambahPaket.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tambahPaketActionPerformed(evt);
            }
        });
        paket.add(tambahPaket);

        jMenuBar1.add(paket);

        member.setText("Member");

        lihatMember.setText("lihat Member");
        lihatMember.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lihatMemberActionPerformed(evt);
            }
        });
        member.add(lihatMember);

        tambahMember.setText("tambah Member");
        member.add(tambahMember);

        jMenuBar1.add(member);

        setJMenuBar(jMenuBar1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void saveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveActionPerformed

        if (jTextField1.getText().equals("") || jTextField2.getText().equals("") || jTextField3.getText().equals("")
                || jTextField4.getText().equals("") || jTextField5.getText().equals("") || jTextField6.getText().equals("")
                || jTextField7.getText().equals("") || jTextField8.getText().equals("") || jDateChooser2.getDate().equals("")) {
            JOptionPane.showMessageDialog(null, "Ada field yang kosong");
        } else {


            Pesanan pesan = new Pesanan();
            pesan.setId_pesanan(jTextField1.getText());
            pesan.setId_member(jTextField2.getText());
            pesan.setNama(jTextField3.getText());
            pesan.setAlamat(jTextField4.getText());
            pesan.setTelp(jTextField5.getText());
            pesan.setPaket(jTextField6.getText());
            int jml = Integer.parseInt(jTextField7.getText());
            Double t = Double.parseDouble(jTextField8.getText());
            Double total = jml * t;
            SimpleDateFormat sdf = new SimpleDateFormat("dd-MMMM-yyyy");
            String tanggal = sdf.format(jDateChooser2.getDate());
            pesan.setJadi(tanggal);
            pesan.setStatus(jComboBox1.getModel().getSelectedItem().toString());
            System.out.println(pesan);
            jTextField1.setText(null);
            jTextField2.setText(null);
            jTextField3.setText(null);
            jTextField4.setText(null);
            jTextField5.setText(null);
            jTextField6.setText(null);
            jTextField7.setText(null);
            jTextField8.setText(null);
            jDateChooser2.setDate(null);
            FormKonfirmasi konfirmasi = new FormKonfirmasi();
            konfirmasi.setVisible(true);
            dispose();


        }
        // TODO add your handling code here:
    }//GEN-LAST:event_saveActionPerformed

    private void jTextField4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField4ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField4ActionPerformed

    private void jTextField7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField7ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField7ActionPerformed

    private void jTextField5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField5ActionPerformed
        angka(jTextField5.getText());
    }//GEN-LAST:event_jTextField5ActionPerformed

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
        angka(jTextField1.getText());
    }//GEN-LAST:event_jTextField1ActionPerformed

    private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField3ActionPerformed
        angka(jTextField3.getText());
    }//GEN-LAST:event_jTextField3ActionPerformed

    private void cancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelActionPerformed
        FormPesanan cancel = new FormPesanan();
        cancel.setVisible(true);
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_cancelActionPerformed

    private void homeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_homeActionPerformed
        FromMenuOperator home = new FromMenuOperator();
        home.setVisible(true);
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_homeActionPerformed

    private void orderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_orderActionPerformed
        FormPesanan pesan = new FormPesanan();
        pesan.setVisible(true);
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_orderActionPerformed

    private void lihatPesananActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lihatPesananActionPerformed
        view_pesanan viewp = new view_pesanan();
        viewp.setVisible(true);
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_lihatPesananActionPerformed

    private void lihatDaftarPaketActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lihatDaftarPaketActionPerformed
        view_menu viewm = new view_menu();
        viewm.setVisible(true);
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_lihatDaftarPaketActionPerformed

    private void tambahPaketActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tambahPaketActionPerformed
        FormMenuTambah addMenu = new FormMenuTambah();
        addMenu.setVisible(true);
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_tambahPaketActionPerformed

    private void lihatMemberActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lihatMemberActionPerformed
        view_member viewber = new view_member();
        viewber.setVisible(true);
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_lihatMemberActionPerformed

    private void jTextField6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField6ActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jTextField6ActionPerformed

    private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField2ActionPerformed

    private void jTextField8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField8ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField8ActionPerformed

    private void menuEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuEditActionPerformed
        FormPesanan edit = new FormPesanan();
        edit.setVisible(true);
        this.dispose();// TODO add your handling code here:
    }//GEN-LAST:event_menuEditActionPerformed

    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBox1ActionPerformed

    private void jDateChooser2AncestorAdded(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_jDateChooser2AncestorAdded
        GregorianCalendar gc = new GregorianCalendar();
        jDateChooser2.setDate(gc.getTime());
        // TODO add your handling code here:
    }//GEN-LAST:event_jDateChooser2AncestorAdded

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        Form_Utama utama = new Form_Utama();
        utama.setVisible(true);
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    /**
     * @param args the command line arguments
     */
    public void angka(String angka) {
        if (!angka.matches("[0-9]*")) {
            JOptionPane.showMessageDialog(this, "Format salah Tolong Isikan angka");
            jTextField1.setText("");
            jTextField3.setText("");
            jTextField5.setText("");
        }
    }

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FormPesanan().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel background;
    private javax.swing.JButton cancel;
    private javax.swing.JMenu file;
    private javax.swing.JMenuItem home;
    private javax.swing.JComboBox jComboBox1;
    private com.toedter.calendar.JDateChooser jDateChooser2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JTextField jTextField7;
    private javax.swing.JTextField jTextField8;
    private javax.swing.JLabel labelHargaTotal;
    private javax.swing.JLabel labelID;
    private javax.swing.JLabel labelJumlah;
    private javax.swing.JLabel labelPaket;
    private javax.swing.JLabel labelTanggalJadi;
    private javax.swing.JLabel labelTelp;
    private javax.swing.JLabel labelnama;
    private javax.swing.JMenuItem lihatDaftarPaket;
    private javax.swing.JMenuItem lihatMember;
    private javax.swing.JMenuItem lihatPesanan;
    private javax.swing.JMenu member;
    private javax.swing.JMenu menuEdit;
    private javax.swing.JMenuItem order;
    private javax.swing.JMenu paket;
    private javax.swing.JButton save;
    private javax.swing.JMenuItem tambahMember;
    private javax.swing.JMenuItem tambahPaket;
    // End of variables declaration//GEN-END:variables
}
